﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework;

namespace ERF.Input
{
    /// <summary>
    /// This class is necessary to handle buttons in a clean way.
    /// This could be removed and replaced by a switch in the GetButtonState method if performance
    /// demands it, But it will be harder adding buttons if you do it in that manner.
    /// </summary>
    public abstract class AssignedButton
    {          
        protected InputHandler handler;

        private TimeSpan lastUsedTime = new TimeSpan();

        public TimeSpan LastUsedTime
        {
            get { return lastUsedTime; }
            set { lastUsedTime = value; }
        }

        /// <summary>
        /// Create a ButtonWrapper object for a key
        /// </summary>
        /// <param name="handler"></param>
        /// <param name="key"></param>
        public AssignedButton(InputHandler handler)
        {
            this.handler = handler;
        }

        /// <summary>
        /// Check if a button was pressed when the input class was updated last.
        /// </summary>
        /// <param name="button"></param>
        /// <returns></returns>
        public abstract bool IsButtonDown();

        /// <summary>
        /// Check if a button was released since the last update
        /// </summary>
        /// <returns></returns>
        public abstract bool IsButtonReleased();
    }
}
